{{- /* Recently updated pages */ -}}
{{- /* TODO refactor to support archives, section, taxonomy and term. */ -}}
{{- if and .Site.Params.section.recentlyUpdated.enable (eq $.Paginator.PageNumber 1) -}}
  {{- $hasTitle := false }}
  {{- $postCount := 0 -}}
  {{- $maxPostCount := .Site.Params.section.recentlyUpdated.maxCount | default 10 -}}
  {{- $days := .Site.Params.section.recentlyUpdated.days | default 30 -}}
  {{- range first $maxPostCount (where .Data.Pages.ByLastmod.Reverse "Section" "!=" "") -}}
    {{- if gt (add .Lastmod.Unix (mul 86900 $days)) now.Unix -}}
      {{- if ne .Lastmod.Unix .Date.Unix }}
        {{- $postCount = add $postCount 1 -}}
        {{- if eq $hasTitle false -}}
          <h2 class="group-title">
            {{- dict "Class" "fa-regular fa-calendar-check fa-fw me-1" | partial "plugin/icon.html" -}}
            {{- T "section.recentlyUpdated" -}}
          </h2>
          {{- $hasTitle = true -}}
        {{- end -}}
        <article class="archive-item">
          <a href="{{ .RelPermalink }}" class="archive-item-link">
            {{- $repost := .Params.repost | default dict -}}
            {{- if eq $repost.enable true -}}
              {{- dict "Class" "fa-solid fa-share fa-fw text-success me-1" | partial "plugin/icon.html" -}}
            {{- end -}}
            {{- title .LinkTitle -}}
          </a>
          <span class="archive-item-date" title='{{ "2006-01-02 15:04:05" | .Lastmod.Format }}'>
            {{- with .Lastmod | dateFormat (.Site.Params.section.dateformat | default "01-02") -}}
              {{- dict "Date" . | T "single.updatedOnDate" -}}
            {{- end -}}
          </span>
        </article>
      {{- end -}}
    {{- end -}}
  {{- end -}}
{{- end -}}
